<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="设备管理" bodyClass="gray-bg animated fadeInRight" isAnimation=false libs=["table","zTree","layout-latest"]/>
<div class="ui-layout-west">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-grid"></i> 设备信息
            </div>
            <div class="box-tools pull-right">
                <!--<a type="button" class="btn btn-box-tool" href="#" onclick="comp()" title="公司管理"><i class="fa fa-edit"></i></a>-->
                <button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新信息"><i class="fa fa-refresh"></i></button>
            </div>
        </div>
        <div class="ui-layout-content">
            <div id="tree" class="ztree"></div>
        </div>
    </div>
</div>
<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <@f.form id="dept-form">
                <input id="equipmentType" name="equipmentType" value="" type="hidden">
                <input id="meteringUnit" name="meteringUnit" value="" type="hidden">
                <input id="depositAddr" name="depositAddr" value="" type="hidden">
                <input id="useDepartment" name="useDepartment" value="" type="hidden">
                <input id="safekeeping" name="safekeeping" value="" type="hidden">
                <input id="increase" name="increase" value="" type="hidden">
                <input id="usages" name="usages" value="" type="hidden">
                <input id="accumulatedDepreciation" name="accumulatedDepreciation" value="" type="hidden">

            </@f.form>
        </div>

            <@table id="bootstrap-table">
                <@shiro.hasPermission name="sys:user:add">
                    <a class="btn btn-success" onclick="opt.operate.addTab()"><i class="fa fa-plus"></i>&nbsp;<@ctx.i18n text = "新增"/></a>
                </@shiro.hasPermission>
                <@shiro.hasPermission name="sys:user:edit">
                    <a class="btn btn-primary single disabled" onclick="opt.operate.editTab()"><i class="fa fa-pencil-square-o"></i>&nbsp;<@ctx.i18n text = "修改"/></a>
                </@shiro.hasPermission>
                <@shiro.hasPermission name="sys:user:del">
                    <a class="btn btn-danger multiple disabled" onclick="opt.operate.delAll()">
                        <i class="fa fa-remove"></i> <@ctx.i18n text = "删除"/>
                    </a>
                </@shiro.hasPermission>
                <@shiro.hasPermission name="sys:user:export">
                    <a class="btn btn-warning" onclick="$.table.exportExcel()">
                        <i class="fa fa-download"></i> 导出
                    </a>
                </@shiro.hasPermission>
            </@table>
        </div>
    </div>
</div>
<@footer>
<script type="text/javascript">

    var editFlag = "${permission.hasPermi('bus:equipment:edit')}";
    var delFlag = "${permission.hasPermi('bus:equipment:del')}";
    var add1Flag = "${permission.hasPermi('bus:repair:add')}";
    var resetPwdFlag = "${permission.hasPermi('sys:user:resetPwd')}";
    var visible = ${permission.isPermitteds("sys:user:edit,sys:user:del,sys:user:resetPwd")?string('true', 'false')};
    var datas = ${dict.getDictListJson('sys_user_show_hide')};
    var prefix = baseURL + 'bus/equipment';
    var prefix1 = baseURL + 'bus/repair';
    $(function() {
        /*初始化页面布局*/
        var panehHidden = false;
        if ($(this).width() < 767) {
            panehHidden = true;
        }
        /*初始化布局*/
        $('body').layout({
            initClosed: panehHidden
            , west__size: 190
            ,west__fxSpeed_size:			"fast"	// 'fast' animation when resizing west-pane
            ,west__fxSpeed_open:			1000	// 1-second animation when opening west-pane
            ,west__fxSettings_open:		{ easing: "easeOutBounce" } // 'bounce' effect when opening
            ,west__fxName_close:			"none"	// NO animation when closing west-pane
        });
        /*加载 树、树表格*/
        initTable();
        initLeftZtree();
    });

    function initTable() {
        /* 初始表格对象 */
        var options = {
            url: prefix + "/list",
            addUrl: prefix1 + "/add{id}",
            editUrl: prefix + "/edit/{id}",
            delUrl: prefix + "/del",
            viewUrl: prefix + "/view/{id}",
            exportUrl:  prefix + "/export",
            clickToSelect: false,

            // resizable: true,
            pageSize: 12,
            pageList: [12, 24, 36],
            sortName: "createTime",
            // fixedColumns: true,
            // fixedNumber: 3,
            // rightFixedColumns: true,
            // rightFixedNumber: 1,
            uniqueId: "id", /* 唯一ID */
            modalName: "设备管理",
            columns: [
                // {field: 'selectItem', radio: true},
                {title: $.i18n.prop("序号"), width: 5, align: "center", formatter: function (value, row, index) {
                        return $.table.serialNumber(index);}},
                // {field : 'id',title : '<@ctx.i18n text = "编号"/>'},
                {field : 'equipmentCode',title : '<@ctx.i18n text = "设备编码"/>'},
                {field : 'equipmentName',title : '<@ctx.i18n text = "设备名称"/>'},

                {field : 'meterageCompany',title : '<@ctx.i18n text = "计量公司"/>'},
                {field : 'companyCode',title : '<@ctx.i18n text = "计量公司编号"/>'},
                {field : 'meterageTime',title : '<@ctx.i18n text = "计量时间"/>'},

                {field : 'meteringUnit',title : '<@ctx.i18n text = "单位"/>'},
                {field : 'equipmentModel',title : '<@ctx.i18n text = "设备型号"/>'},
                {field : 'usages',title : '<@ctx.i18n text = "使用情况"/>'},
                {field : 'useDepartment',title : '<@ctx.i18n text = "使用部门"/>'},
                {field : 'safekeeping',title : '<@ctx.i18n text = "保管人员"/>'},
                {field : 'depositAddr',title : '<@ctx.i18n text = "存放地点"/>'},
                {field : 'equipmentValue',title : '<@ctx.i18n text = "设备原值"/>'},
                {field : 'manufacturer',title : '<@ctx.i18n text = "制造厂家"/>'},
                {field : 'standardCode',title : '<@ctx.i18n text = "国标编号"/>'},
                {field : 'configure',title : '<@ctx.i18n text = "详细配置"/>'},
                {field : 'purchaseTime',title : '<@ctx.i18n text = "购买日期"/>'},
                {field : 'productionTime',title : '<@ctx.i18n text = "出厂日期"/>'},
                {field : 'putTime',title : '<@ctx.i18n text = "入账日期"/>'},
                {field : 'increase',title : '<@ctx.i18n text = "增加方式"/>'},
                {field : 'depreciation',title : '<@ctx.i18n text = "折旧方法"/>'},
                {field : 'jingcanValue',title : '<@ctx.i18n text = "净残值率"/>'},
                {field : 'age',title : '<@ctx.i18n text = "使用年限"/>'},
                {field : 'accumulatedDepreciation',title : '<@ctx.i18n text = "累计折旧"/>'},
                {field : 'worth',title : '<@ctx.i18n text = "净值"/>'},
                {field : 'classifyCode',title : '<@ctx.i18n text = "分类编码"/>'},
                {field : 'equipmentType',title : '<@ctx.i18n text = "分类名称"/>'},
                {title:"<@ctx.i18n text = "操作"/>",align: 'left',class:'action',formatter: function(value, row, index) {
                        var actions = [];
                        // actions.push('<a class="" href="javascript:void(0)" title="<@ctx.i18n text = "关联流程表单"/>" onclick="taskFrom(\'' + row.id + '\')"><i class="fa icon-organization"></i></a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick=" opt.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i><@ctx.i18n text = "编辑"/></a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + delFlag + '" href="javascript:void(0)" onclick="opt.operate.del(\'' + row.id + '\')"><i class="fa fa-remove"></i> <@ctx.i18n text = "删除"/></a>');
                        actions.push('<a class="btn btn-success btn-xs ' + add1Flag + '" href="javascript:void(0)" onclick="repair(\'' + row.id + '\')"><i class="fa fa-edit"></i><@ctx.i18n text = "设备维修"/></a> ');
                        return actions.join('');
                    }}
            ]
        };
        $.table.init(options);
    }
    var leftButTag = false;
    function popupRight(id){
        opt.modal.popupRight("用户信息",prefix + "/view/"+id,delFlag == '',opt.operate.edit,id);
    }
    /* 用户管理-重置密码 */
    function repair(id) {
        console.log("111111")
        console.log(id)
        console.log("11111111")
        opt.modal.openTab("设备维修",prefix + "/repair/"+id);
    }


    /*初始化左侧树*/
    function initLeftZtree() {
        var options = {
            url: baseURL+"bus/classify/treeData",
            displayLen: 12,
            expandLevel:1,
            onClick : onClick,
            check: {
                enable: false
            }
        };
        $.tree.init(options);
    }

    /* 点击左侧数节点 回调事件 刷新表格*/
    function onClick(event, treeId, treeNode) {
        leftButTag = true;
        console.log(treeNode);
        console.log(treeNode.name);
        console.log(treeNode.pId);
        $("#equipmentType").val("");
        $("#meteringUnit").val("");
        $("#depositAddr").val("");
        $("#useDepartment").val("");
        $("#safekeeping").val("");
        $("#increase").val("");
        $("#usages").val("");
        $("#accumulatedDepreciation").val("");
        if(treeNode.pId){
           var  pid=treeNode.pId;
            switch(pid) {
                case "1":
                    console.log(treeNode.name);
                    console.log("5555555343");
                    $("#equipmentType").val(treeNode.name);
                    break;
                case "2":
                    $("#meteringUnit").val(treeNode.name);
                    break;
                case "3":
                    $("#depositAddr").val(treeNode.name);
                    break;
                case "4":
                    $("#useDepartment").val(treeNode.name);
                    break;
                case "5":
                    $("#safekeeping").val(treeNode.name);
                    break;
                case "6":
                    $("#increase").val(treeNode.name);
                    break;
                case "7":
                    $("#usages").val(treeNode.name);
                    break;
                case "8":
                    $("#accumulatedDepreciation").val(treeNode.name);
                    break;


            }

        }


      //  $("#meteringUnit").val(treeNode.name);

        $.table.search();

    }

    /* 左侧数刷新事件*/
    $('#btnRefresh').click(function() {
        initLeftZtree();
    });

    /* 左侧树展开事件 */
    $('#btnExpand').click(function() {
        $._tree.expandAll(true);
        $(this).hide();
        $('#btnCollapse').show();
    });

    /* 左侧树折叠事件 */
    $('#btnCollapse').click(function() {
        $._tree.expandAll(false);
        $(this).hide();
        $('#btnExpand').show();
    });

    function comp() {
        var url = baseURL + "sys/dept";
        opt.modal.openTab("机构管理", url);
    }

    /* 点击树组件 回调事件案例 回调方法名固定 刷新表格*/
    /**
     *  id 为组件id
     *  event 为组件点击按钮名称 ok 确定 clear 清除 cancel 取消
     *  index 弹出窗口index
     *  layero
     *  nodes 确认事件传的参数
     **/
    function treeCallback(id, event, index, layero, nodes) {
        if(id == "compId"){
            if(event == "ok"){
                /* 点击确认按钮直接刷新表格*/
                $.table.search();
            }
        }
    }


</script>
</@footer>
</@pageTheme>